//
//  MyViewController.m
//  iOS-Demo
//
//  Created by wsj2015 on 16/6/29.
//  Copyright © 2016年 ljh. All rights reserved.
//

#import "MyViewController.h"
#import <sqlite3.h>
@interface MyViewController ()

@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    ;
    NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0] stringByAppendingString:@"students.sqlite"];
    
    sqlite3 *db = nil;
    if (sqlite3_open(filePath.UTF8String, &db) == SQLITE_OK) {
        NSLog(@"数据库打开成功");
    }
    
    
    //创建表
    
    NSString *sql =@"create table if not exists t_student(id integer primary key autoincrement, name text,age integer);";
    char *errmsg;
    sqlite3_exec(db, sql.UTF8String, NULL, NULL, &errmsg);
    if (errmsg) {
        NSLog(@"创建表失败%@",[NSString stringWithUTF8String:errmsg]);
    }
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
